package com.mspbots.teams.controller;

import com.mspbots.teams.model.Messages;
import com.mspbots.teams.model.TeamsCommand;
import com.mspbots.teams.model.TeamsMessageDTO;
import com.mspbots.teams.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.Callable;

@Slf4j
@RestController
@RequestMapping("message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    @PostMapping("send")
    public Callable send(@RequestBody TeamsMessageDTO teamsMessage) {
        return () -> messageService.send(teamsMessage);
    }

    @PostMapping("saveMessage")
    public Callable saveMessage(@RequestBody TeamsMessageDTO teamsMessage) {
        return () -> messageService.saveMessage(teamsMessage);
    }

    @PostMapping("reply")
    public Callable reply(@RequestBody Messages messages) {
        return () -> messageService.reply(messages);
    }

    @PostMapping("command")
    public Callable sendStatus(@RequestBody TeamsCommand teamsCommand) {
        return () -> messageService.command(teamsCommand);
    }

    @GetMapping("healthcheck")
    public Callable healthcheck() {
        return () -> true;
    }
}
